#include "StdAfx.h"

typedef void(__stdcall* fnDynamic)();
int32_t wmain(int32_t nArgc, const wchar_t* pArgv[]) {
	printf("... current PID: %d\r\n", GetCurrentProcessId());
	//system("pause");
	if (nArgc < 2) {
		printf("... usage: %ws <shellcode file path>\r\n", pArgv[0]);
	}
	else {
		FileBase ShellcodeFile(pArgv[1]);
		uint8_t* pDynamicMem = (uint8_t *)VirtualAlloc(nullptr, ShellcodeFile.GetSize() + 0x5000, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
		memcpy(pDynamicMem + 0x3000, ShellcodeFile.GetData(), ShellcodeFile.GetSize());
		((fnDynamic)(pDynamicMem + 0x3000))();
	}

	system("pause");
	return 0;
}